package com.ssy.lingxi.sms.api.feign;

import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.sms.api.entity.SmsConfig;
import com.ssy.lingxi.sms.api.hystrix.ConfigSmsHystrix;
import com.ssy.lingxi.sms.api.model.SmsConfigVO;
import com.ssy.lingxi.sms.api.model.request.DeleteConfigRequest;
import com.ssy.lingxi.sms.api.model.request.SimpleIdRequest;
import com.ssy.lingxi.sms.api.model.request.TemplateRequest;
import com.ssy.lingxi.sms.api.model.response.TemplateResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;

/**
 * @menu: 短信配置服务
 * 短信服务器配置接口
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/15
 */
@FeignClient(value = "sms-service", fallback = ConfigSmsHystrix.class)
public interface IConfigSmsFeign {

    /**
     * 查询当前配置的服务商类型
     * @return 服务商类型: 1-腾讯云，2-阿里云
     */
    @RequestMapping(value = "/sms/getServiceType", method = RequestMethod.GET)
    Wrapper<Integer> getServiceType();

    /**
     * 查询参数代码
     * @param serviceType 服务商类型: 1-腾讯云，2-阿里云
     * @return SmsConfig
     */
    @RequestMapping(value = "/sms/getParamCode", method = RequestMethod.GET)
    Wrapper<HashMap<String, String>> getParamCode(@RequestParam("serviceType") Integer serviceType);

    /**
     * 查询配置信息
     * @param serviceType 服务商类型: 1-腾讯云，2-阿里云
     * @return SmsConfig
     */
    @RequestMapping(value = "/sms/getSmsConfig", method = RequestMethod.GET)
    Wrapper<SmsConfig> getSmsConfig(@RequestParam("serviceType") Integer serviceType);

    /**
     * 添加/修改短信服务器配置
     * @param smsConfigVO 配置参数
     * @return 是否成功
     */
    @RequestMapping(value = "/sms/saveOrUpdateSmsConfig", method = RequestMethod.POST)
    Wrapper<Boolean> saveOrUpdateSmsConfig(@RequestBody SmsConfigVO smsConfigVO);

    /**
     * 删除短信服务器配置
     * @param deleteConfigRequest 参数
     * @return 是否成功
     */
    @RequestMapping(value = "/sms/deleteSmsConfig",method = RequestMethod.POST)
    Wrapper<Boolean> deleteSmsConfig(@RequestBody DeleteConfigRequest deleteConfigRequest);

    /**
     * 查询功能模块代码
     * @return SmsConfig
     */
    @RequestMapping(value = "/sms/getModuleCode", method = RequestMethod.GET)
    Wrapper<HashMap<String, String>> getModuleCode();

    /**
     * 查询短信内容模板
     * @param pageVO 分页实体
     * @return 短信内容模板
     */
    @RequestMapping(value = "/sms/getSmsTemplateList", method = RequestMethod.GET)
    Wrapper<PageData<TemplateResponse>> getSmsTemplateList(PageVO pageVO);

    /**
     * 新增/修改短信内容模板
     * @param templateVO 模板参数
     * @return 是否成功
     */
    @RequestMapping(value = "/sms/saveOrUpdateSmsTemplate", method = RequestMethod.POST)
    Wrapper<Boolean> saveOrUpdateSmsTemplate(@RequestBody TemplateRequest templateVO);

    /**
     * 删除短信内容模板
     * @param simpleIdRequest 短信内容模板id
     * @return 是否成功
     */
    @RequestMapping(value = "/sms/deleteSmsTemplate", method = RequestMethod.POST)
    Wrapper<Boolean> deleteSmsTemplate(@RequestBody SimpleIdRequest simpleIdRequest);

    /**
     * 清空短信内容模板
     * @return 是否成功
     */
    @RequestMapping(value = "/sms/clearSmsTemplate", method = RequestMethod.POST)
    Wrapper<Boolean> clearSmsTemplate();
}
